package src;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.HelpListener;
import org.eclipse.swt.events.HelpEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Button;
import org.eclipse.wb.swt.SWTResourceManager;

public class About extends Dialog
{

	protected Object	result;
	protected Shell		shlAbout;

	/**
	 * Create the dialog.
	 * 
	 * @param parent
	 * @param style
	 */
	public About(Shell parent, int style)
	{
		super(parent, style);
		setText("SWT Dialog");

	}

	/**
	 * Open the dialog.
	 * 
	 * @return the result
	 */
	public Object open()
	{
		createContents();
		shlAbout.open();
		shlAbout.layout();
		Display display = getParent().getDisplay();

		while (!shlAbout.isDisposed())
		{
			if (!display.readAndDispatch())
			{
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents()
	{
		shlAbout = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		shlAbout.addHelpListener(new HelpListener()
		{
			public void helpRequested(HelpEvent arg0)
			{
				Help.show();
			}
		});
		shlAbout.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
		shlAbout.setImage(org.eclipse.wb.swt.SWTResourceManager.getImage(About.class, "/src/icon/world.ico"));
		shlAbout.setSize(322, 183);
		shlAbout.setText("About");
		shlAbout.setLayout(null);

		Button btnNewButton = new Button(shlAbout, SWT.NONE);
		btnNewButton.setSelection(true);
		btnNewButton.addMouseListener(new MouseAdapter()
		{
			@Override
			public void mouseUp(MouseEvent e)
			{
				shlAbout.close();
			}
		});
		btnNewButton.setBounds(240, 120, 68, 23);
		btnNewButton.setText("OK");

		Composite composite = new Composite(shlAbout, SWT.NONE);
		composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND));
		composite.setBounds(0, 0, 348, 70);

		Label lblNewLabel = new Label(composite, SWT.NONE);
		lblNewLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND));
		lblNewLabel.setLocation(20, 10);
		lblNewLabel.setSize(217, 23);
		lblNewLabel.setFont(SWTResourceManager.getFont("Arial Rounded MT Bold", 14, SWT.BOLD));
		lblNewLabel.setText("Kepler problem in 3d");

		Label lblNewLabel_1 = new Label(composite, SWT.NONE);
		lblNewLabel_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND));
		lblNewLabel_1.setLocation(33, 37);
		lblNewLabel_1.setSize(70, 13);
		lblNewLabel_1.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.NORMAL));
		lblNewLabel_1.setText("Version: 0.2");

		Label lblNewLabel_2 = new Label(composite, SWT.NONE);
		lblNewLabel_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND));
		lblNewLabel_2.setImage(org.eclipse.wb.swt.SWTResourceManager.getImage(About.class, "/src/icon/Earth.png"));
		lblNewLabel_2.setBounds(240, 0, 79, 70);

		Label lblNewLabel_3 = new Label(shlAbout, SWT.NONE);
		lblNewLabel_3.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblNewLabel_3.setBounds(10, 76, 298, 38);
		lblNewLabel_3.setText("OpenGL application implementing the solution \r\nof the kepler problem.");

		Label lblNewLabel_4 = new Label(shlAbout, SWT.NONE);
		lblNewLabel_4.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL));
		lblNewLabel_4.setBounds(20, 125, 142, 13);
		lblNewLabel_4.setText("Developed: Kirill Pletnev");

	}
}
